package com.alliky.core.base

import com.alliky.core.ext.showToast

abstract class BaseActivity<in V : IView, P : IPresenter<V>> : BasicActivity(), IView {

    var mPresenter: P? = null
    protected abstract fun createPresenter(): P

     override fun initView() {
        mPresenter = createPresenter()
        mPresenter?.attachView(this as V)
    }

    override fun onDestroy() {
        super.onDestroy()
        mPresenter?.detachView()
        this.mPresenter = null
    }

    override fun showLoading() {

    }

    override fun hideLoading() {

    }

    override fun showError(message: String) {
        showToast(message)
    }

    override fun showMessage(message: String) {
        showToast(message)
    }

    override fun showDefaultMsg(message: String) {
        showToast(message)
    }
}